//
//  LSZSpecialPackaging.m
//  JKFuYinProject
//
//  Created by 九酷 on 2017/9/19.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LSZSpecialPackaging.h"
#import "JKSongsMessStatus.h"
#import "LCPlaylist.h"
#import "NetworkTool+LCAVPlay.h"
#import <ShareSDK/ShareSDK.h>
#import <ShareSDKUI/ShareSDK+SSUI.h>
#import <WXApi.h>
#import "Reachability.h"

@implementation LSZSpecialPackaging
#pragma mark - 在view上 任意话一条线自定义颜色
+(id)addThreadWithOtherRGB:(UIView *)view A:(NSInteger)A B:(NSInteger)B C:(NSInteger)C D:(NSInteger)D R:(NSInteger)R G:(NSInteger)G BB:(NSInteger)BB
{
    //    添加下边边的边框
    CALayer *layer2 = [CALayer layer];
    layer2.frame = CGRectMake(A,B,C,D);
    layer2.backgroundColor = RGBColor(R,G,BB).CGColor;
    [view.layer addSublayer:layer2];
    return view;
}
#pragma mark - 时间戳的转换
+(NSString *)TimeStamp:(NSString *)strTime
{
    NSInteger fen = [strTime integerValue]/60000;
    NSInteger miao = [strTime integerValue]%60000/1000;
    NSString * timeStr = [[NSString alloc]init];
     if (fen<10) {
         if (miao<10) {
             timeStr = [NSString stringWithFormat:@"0%zd:0%zd", fen,miao];
         }else
         timeStr = [NSString stringWithFormat:@"0%zd:%zd", fen,miao];
     }else{
         if (miao<10) {
             timeStr = [NSString stringWithFormat:@"%zd:0%zd", fen,miao];
         }else
             timeStr  = [NSString stringWithFormat:@"%zd:%zd", fen,miao];
     }
    return timeStr;
}
#pragma mark - 获取之前的时间和现在的比  GetTime 2017-10-30 12:04:07
+(NSString *)GetThePreviousTimeAndCompareItNow:(NSString *)GetTime
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *timeDate = [dateFormatter dateFromString:GetTime];
    NSDate *currentDate = [NSDate date];
    NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:timeDate];
    long temp = 0;
    NSString *resultTime = [[NSString alloc]init];
    if (timeInterval/60 < 1) {
        resultTime = [NSString stringWithFormat:@"刚刚"];
    }
    else if((temp = timeInterval/60) <60){
        resultTime = [NSString stringWithFormat:@"%zd分钟前",temp];
    }
    else if((temp = temp/60) <24){
        resultTime = [NSString stringWithFormat:@"%zd小时前",temp];
    }
    else if((temp = temp/24) <30){
        resultTime = [NSString stringWithFormat:@"%zd天前",temp];
    }
    else if((temp = temp/30) <12){
        resultTime = [NSString stringWithFormat:@"%zd月前",temp];
    }
    else{
        temp = temp/12;
        resultTime = [NSString stringWithFormat:@"%zd年前",temp];
    }
    return resultTime;
}
#pragma mark - 获取当前月
+(NSString *)GetTheCurrentMonth
{
    NSCalendar *gregorian = [[NSCalendar alloc]
                             initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    // 获取当前日期
    NSDate* dt = [NSDate date];
    // 定义一个时间字段的旗标，指定将会获取指定年、月、日、时、分、秒的信息
    unsigned unitFlags = NSCalendarUnitMonth;
    // 获取不同时间字段的信息
    NSDateComponents* comp = [gregorian components: unitFlags
                                          fromDate:dt];
    NSString * month = [NSString stringWithFormat:@"%zd",comp.month];
    return  month;
}
#pragma mark - 获取当前时间
+(NSString *)GetTheCurrentMonthDay
{
    NSDate *senddate = [NSDate date];
//    NSString *date2 = [NSString stringWithFormat:@"%ld", (long)[senddate timeIntervalSince1970]];
     NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSString *date1 = [dateformatter stringFromDate:senddate];
    return date1;
}
+(NSString *)addPlaylistWithArrayData:(NSArray *)arrayData
{
    JKSongsMessResult * results = [[JKSongsMessResult alloc] init];
     NSArray *arr = [NSArray yy_modelArrayWithClass:[JKSongsMessStatus class] json:arrayData];
    results.data = arr;
    LCPlaylist *playlist = [LCPlaylist new];
    playlist.name = @"playlist01";
    for (JKSongsMessStatus *songDictionary in arr)
    {
        songDictionary.filePath = [NSString stringWithFormat:@"%@", [kNetworkTool mp3WithUrl:songDictionary.fileUrl]];//歌曲文件
        [playlist addSong:songDictionary];
    }
    [_PlaylistMgr removeAllPlaylists];
    [_PlaylistMgr addPlaylist:playlist];
    //这个明天做
    NSString * Strva = [NSString stringWithFormat:@"%@",_LCPlayer.valueDistinguish];
    NSString * strValue = [NSString stringWithFormat:@"%@",NullStringjudgment(Strva)];
    return strValue;
}
+ (NSString *)addPlaylistWithArrayData:(NSArray *)arrayData image:(NSString *)image{
    NSArray *arr = [NSArray yy_modelArrayWithClass:[JKSongsMessStatus class] json:arrayData];
    LCPlaylist *nowPlaylist = [LCPlaylist new];
    for (JKSongsMessStatus *songDictionary in arr) {
        songDictionary.filePath = [NSString stringWithFormat:@"%@", [kNetworkTool mp3WithUrl:songDictionary.fileUrl]];//歌曲文件
        songDictionary.image = image;//歌曲专辑图
        [nowPlaylist addSong:songDictionary];
    }
    if ([self getDuplicationCheckWithArr:nowPlaylist.allSongs]) {
        return @"";
    }
    [_PlaylistMgr removeAllPlaylists];
    [_PlaylistMgr addPlaylist:nowPlaylist];
    //这个明天做
    NSString * Strva = [NSString stringWithFormat:@"%@",_LCPlayer.valueDistinguish];
    NSString * strValue = [NSString stringWithFormat:@"%@",NullStringjudgment(Strva)];
    return strValue;
}
+ (BOOL)getDuplicationCheckWithArr:(NSArray *)arr {
    if (_LCPlayer.songs.count == arr.count) {//假如之前列表 和 当前列表数量相同 则return退出
        //且每一首歌曲都相同
        BOOL duplicateSong = YES;
        for (NSInteger i = 0; i < arr.count; i++) {
            JKSongsMessStatus *song = arr[i];
            //不能使用id比较,因为Model不一样
            if (![song.fileUrl isEqualToString:_LCPlayer.songs[i].fileUrl]) {
                duplicateSong = NO;
                break;
            }
        }
        if (duplicateSong == YES) {
            return YES;
        }
    }
    return NO;
}
#pragma mark - 分享
+(void)shareShengJingMessageWithViewController:(UIViewController *)viewController
                                    imageArray:(NSArray *)imageArray
                                      url:(NSString *)url
                                         title:(NSString *)title
                                contentMessage:(NSString *)messageBody
                                          type:(SSDKContentType)type{
         //1、创建分享参数
    if (imageArray) {
        
    }else{
        imageArray = @[[UIImage imageNamed:@"我的_设置_关于"]];
    }
    if (url) {
        
    }else{
        url = @"http://www.9ku.com/down/fuyin/pc/";
    }
         if (title) {
            //
            NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
            [shareParams SSDKSetupShareParamsByText:messageBody
                                             images:imageArray
                                                url:[NSURL URLWithString:url]
                                              title:title
                                               type:type];
            //            //2、分享（可以弹出我们的分享菜单和编辑界面）
             [[NSOperationQueue mainQueue] addOperationWithBlock:^{//-[UIApplication canOpenURL:] must be used from main thread only
                
                [ShareSDK showShareActionSheet:nil items:nil shareParams:shareParams onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
                    
                    switch (state) {
                        case SSDKResponseStateSuccess:
                        {
                            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"分享成功"
                                                                                           message:nil
                                                                                    preferredStyle:UIAlertControllerStyleAlert];
                            
                            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault
                                                                                  handler:^(UIAlertAction * action) {}];
                            
                            [alert addAction:defaultAction];
                            
                            [viewController presentViewController:alert animated:YES completion:nil];
                            break;
                        }
                        case SSDKResponseStateFail:
                        {
                            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"分享失败"
                                                                                           message:[NSString stringWithFormat:@"%@",error]
                                                                                    preferredStyle:UIAlertControllerStyleAlert];
                            
                            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault
                                                                                  handler:^(UIAlertAction * action) {}];
                            
                            [alert addAction:defaultAction];
                            [viewController presentViewController:alert animated:YES completion:nil];
                            break;
                        }
                        default:
                            break;
                    }
                    
                }];
                 
             }];
        }
}
+(void)shareWXWithViewController:(UIViewController *)viewController
                           imageArray:(NSArray *)imageArray
                                  url:(NSString *)url
                                title:(NSString *)title
                       contentMessage:(NSString *)messageBody
                                 type:(int)type{
        WXMediaMessage *message = [WXMediaMessage message];
        // 标题
        message.title = title;//@"音乐标题";
        // 描述内容
        message.description = messageBody;//@"音乐描述";
        [message setThumbImage:[UIImage imageNamed:@"placeholder"]];
        
        // 多媒体消息中包含的音乐数据对象
        WXMusicObject *ext = [WXMusicObject object];
        // 音乐网页的url地址
        ext.musicUrl = url;//@"音乐url";
        // 音乐lowband数据url地址
        ext.musicLowBandDataUrl = ext.musicUrl;
        // 音乐数据url地址
        ext.musicDataUrl = url;//@"音乐数据url";
        // 音乐lowband数据url地址
        ext.musicLowBandDataUrl = ext.musicDataUrl;
        message.mediaObject = ext;
        
        SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
        req.bText = NO;
        req.message = message;
        req.scene = type;

        [WXApi sendReq:req];
}
#pragma mark - 判断手机号
+ (BOOL)isValidateMobile:(NSString *)mobile
{
    //手机号以13， 15，18开头，八个 \d 数字字符
//    NSString *phoneRegex = @"^((13[0-9])|(15[0-9])|(147)|(148)|(198)|(146)|(166)|(174)|(199)|(17[0-9])|(18[0,0-9]))\\d{8}$";
//    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
//    return [phoneTest evaluateWithObject:mobile];
    return YES;
}
#pragma mark - 判断有没有网络
+ (void)Reachability:(strNetwork)block
{
    Reachability *reach = [Reachability reachabilityWithHostName:@"http://baidu.com"];
    if ([reach currentReachabilityStatus] == NotReachable){
        block(NoNetwork);
    }else{
        block(NoServices);
    }
}
#pragma mark - 分享
+(void)initAlterView:(UIView *)view :(AlterView)block
{
    UIView * viewLow = [[UIView alloc]init];
    viewLow.backgroundColor = RGBColor(246, 246, 246);
    [view addSubview:viewLow];
    if (ScreenWidth == 320) {
        //5
        viewLow.frame = CGRectMake(0, ScreenHeight-WidthScal_320(55)-20-50, ScreenWidth, WidthScal_320(55)+20+50);
    }else if(ScreenWidth == 375){
        // 6 7
        viewLow.frame = CGRectMake(0, ScreenHeight-WidthScal_320(55)-20-60, ScreenWidth, WidthScal_320(55)+20+60);
    }else {
        //plus
        viewLow.frame = CGRectMake(0, ScreenHeight-WidthScal_320(55)-20-68, ScreenWidth, WidthScal_320(55)+20+68);
    }
    UIButton * buttonFriends = [[UIButton alloc]initWithFrame:CGRectMake(WidthScal_320(25), 10,WidthScal_320(55),WidthScal_320(55))];
    [buttonFriends setImage:[UIImage imageNamed:@"分享_微信_弹窗"] forState:UIControlStateNormal];
    [viewLow addSubview:buttonFriends];

    UIButton * buttonFriendsCircle = [[UIButton alloc]initWithFrame:CGRectMake(WidthScal_320(45)+CGRectGetMaxX(buttonFriends.frame), 10,WidthScal_320(55),WidthScal_320(55) )];
    [buttonFriendsCircle setImage:[UIImage imageNamed:@"分享_朋友圈_弹窗"] forState:UIControlStateNormal];
    [viewLow addSubview:buttonFriendsCircle];

    UIButton * buttonDownload = [[UIButton alloc]initWithFrame:CGRectMake(WidthScal_320(45)+CGRectGetMaxX(buttonFriendsCircle.frame), 10,WidthScal_320(55),WidthScal_320(55))];
    [buttonDownload setImage:[UIImage imageNamed:@"下载"] forState:UIControlStateNormal];
    [viewLow addSubview:buttonDownload];

    UIButton * butCancel = [[UIButton alloc]init];
    butCancel.backgroundColor = [UIColor whiteColor];
    [butCancel setTitleColor:titleColorLSZ forState:UIControlStateNormal];
    [butCancel setTitle:@"取消" forState:UIControlStateNormal];
    [viewLow addSubview:butCancel];
    if (ScreenWidth == 320) {
        //5
        butCancel.frame = CGRectMake(0, CGRectGetMaxY(buttonDownload.frame)+10, ScreenWidth, 50);
    }else if(ScreenWidth == 375){
        // 6 7
        butCancel.frame = CGRectMake(0, CGRectGetMaxY(buttonDownload.frame)+10, ScreenWidth, 60);
    }else {
        //plus
        butCancel.frame = CGRectMake(0, CGRectGetMaxY(buttonDownload.frame)+10, ScreenWidth, 68);
    }
    block(viewLow,viewLow,buttonFriends,buttonFriendsCircle,buttonDownload,butCancel);
}

///删除UIWebView 中的缓存
+ (void)clearUIWebViewCacheForLink:(NSString *)link {
    NSURL *url = [NSURL URLWithString:link];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    //    NSURLCache *sharedCache = [[NSURLCache alloc] init];
    //    [sharedCache removeCachedResponseForRequest:request];
    //    [NSURLCache setSharedURLCache:sharedCache];
    [[NSURLCache sharedURLCache] removeCachedResponseForRequest:request];
}
///删除UIWebView 中All的缓存
+ (void)clearUIWebViewAllCache {
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
    [[NSURLCache sharedURLCache] setDiskCapacity:0];
    [[NSURLCache sharedURLCache] setMemoryCapacity:0];
}
///清除cookies
+ (void)clearCookies {
    NSHTTPCookie *cookie;
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (cookie in [storage cookies]) {
        [storage deleteCookie:cookie];
    }
}
#pragma mark - 获取自适应宽度
+(CGFloat)getsTheAdaptiveWidth:(UILabel *)label sizeMaxWidth:(CGFloat)sizeMaxWidth
{
    CGSize size = CGSizeMake(sizeMaxWidth, MAXFLOAT);//设置高度宽度的最大限度
    CGRect rect = [label.text boundingRectWithSize:size options:NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : label.font} context:nil];
    return rect.size.width;
}
+(CGFloat)caculateWidthOfText :(CGFloat)width height:(CGFloat)height font:(CGFloat)font :(NSString * )text
{
    //1.限制大小 2.绘制选项 3.属性（字号大小） 4.一般传nil
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, height) options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:font]} context:nil];
    CGFloat whatWidth = ceilf(rect.size.width);
    return whatWidth+20;
}
+(CGFloat)caculateHeightOfText :(CGFloat)width height:(CGFloat)height font:(CGFloat)font :(NSString * )text
{
    //1.限制大小 2.绘制选项 3.属性（字号大小） 4.一般传nil
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, height) options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:font]} context:nil];
    CGFloat whatHeight = ceilf(rect.size.height);
    return whatHeight+20;
}
#pragma mark - 祷告浏览数增加
+(void)addPrayerNumber:(NSString *)id_id :(isOk)block
{
    [LSZRequestData AddIncreasePrayerTraffic:id_id :^(BOOL isOK, NSString * str, NSDictionary * dic) {
        if (isOK == YES) {
            block(YES);
        }else{
            block(NO);
        }
    }];
}
#pragma mark - //1有分享  其他没分享
+(void)initWithAppraise:(UIView *)view share:(NSInteger)share :(strPinglLun)block
{
    UIView * lowView = [[UIView alloc]init];
    lowView.backgroundColor = [UIColor whiteColor];
    [view addSubview:lowView];
    if (iPhoneX) {
        [lowView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_left).offset(0);
            make.right.equalTo(view.mas_right).offset(0);
            make.bottom.equalTo(view.mas_bottom).offset(-15);
            make.height.mas_equalTo(@48);
        }];
    }else{
        [lowView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_left).offset(0);
            make.right.equalTo(view.mas_right).offset(0);
            make.bottom.equalTo(view.mas_bottom).offset(0);
            make.height.mas_equalTo(@48);
        }];
    }


    UIView * viewBackColor = [[UIView alloc]init];
    [viewBackColor.layer setMasksToBounds:YES];
    [viewBackColor.layer setCornerRadius:16.5];
    viewBackColor.backgroundColor = RGBColor(243, 243, 243);
    [lowView addSubview:viewBackColor];

    [viewBackColor mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lowView.mas_left).offset(15);
        make.right.equalTo(lowView.mas_right).offset(-60);
        make.bottom.equalTo(lowView.mas_bottom).offset(-8);
        make.top.equalTo(lowView.mas_top).offset(7.5);
    }];

    UIImageView * imageViewBi = [[UIImageView alloc]init];
    imageViewBi.image = [UIImage imageNamed:@"编辑"];
    [viewBackColor addSubview:imageViewBi];

    [imageViewBi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(viewBackColor.mas_left).offset(15);
        //        make.right.equalTo(viewBackColor.mas_right).offset(-60);
        make.bottom.equalTo(viewBackColor.mas_bottom).offset(-6.5);
        make.top.equalTo(viewBackColor.mas_top).offset(8.5);
        //        make.height.mas_equalTo(@15);
    }];

    UITextView * textView = [[UITextView alloc]init];
    //    textView. = @"点击此处说两句...";
    //    textView.scrollEnabled = NO;
    textView.scrollsToTop = NO;
    textView.font = [UIFont systemFontOfSize:14];
    textView.backgroundColor = RGBColor(243, 243, 243);
    //当textview的字符串为0时发送（rerurn）键无效
    textView.enablesReturnKeyAutomatically = YES;
    textView.keyboardType = UIKeyboardTypeDefault;
    //    //键盘return样式变成发送
    textView.returnKeyType = UIReturnKeySend;
    [viewBackColor addSubview:textView];

    [textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(viewBackColor.mas_left).offset(35);
        make.right.equalTo(viewBackColor.mas_right).offset(-10);
        make.bottom.equalTo(viewBackColor.mas_bottom).offset(0);
        make.top.equalTo(viewBackColor.mas_top).offset(0);
        //        make.height.mas_equalTo(@15);
    }];
    UILabel * uilabel = [[UILabel alloc]init];
    uilabel.text = @"请填写详细地址";
    uilabel.enabled = NO;//lable必须设置为不可用
    uilabel.font = [UIFont systemFontOfSize:13];
    uilabel.backgroundColor = [UIColor clearColor];
    [textView addSubview:uilabel];
    //WithFrame:CGRectMake(2,3, textView.frame.size.width, 20
    [uilabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(textView.mas_left).offset(3);
        make.right.equalTo(textView.mas_right).offset(-0);
        make.bottom.equalTo(textView.mas_bottom).offset(-10);
        make.top.equalTo(textView.mas_top).offset(10);
        //        make.height.mas_equalTo(@15);
    }];

    UIButton * shareBut = [[UIButton alloc]init];
    [lowView addSubview:shareBut];
    if (share == 1) {
        shareBut.hidden = NO;
    }else{
        shareBut.hidden = YES;
    }
    [lowView addSubview:shareBut];

    [shareBut mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.left.equalTo(viewBackColor.mas_left).offset(35);
        make.right.equalTo(lowView.mas_right).offset(0);
        make.bottom.equalTo(lowView.mas_bottom).offset(0);
        make.top.equalTo(lowView.mas_top).offset(0);
        make.width.mas_equalTo(@48);
    }];

    UIImageView * imageShare = [[UIImageView alloc]initWithFrame:CGRectMake(15, 13, 20.5, 20.5)];
    imageShare.image = [UIImage imageNamed:@"分享"];
    [shareBut addSubview:imageShare];

    [imageShare mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(shareBut.mas_left).offset(15);
        //        make.right.equalTo(shareBut.mas_right).offset(0);
        make.bottom.equalTo(shareBut.mas_bottom).offset(-14.5);
        make.top.equalTo(shareBut.mas_top).offset(13);
        make.width.mas_equalTo(@20.5);
    }];
    block(lowView,textView,uilabel,shareBut,imageShare);
}
+(NSString *)GetThePreviousTime1970:(NSString *)GetTime
{
    // 格式化时间
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    formatter.timeZone = [NSTimeZone timeZoneWithName:@"shanghai"];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

    // 毫秒值转化为秒
    NSDate* date = [NSDate dateWithTimeIntervalSince1970:[GetTime doubleValue]/ 1000.0];
    NSString* dateString = [formatter stringFromDate:date];
    return dateString;
}
///设置自适应文字大小
+ (UIFont *)setlabelTextFontAdaptiveSize:(CGFloat)size {
    UIFont *font = [UIFont systemFontOfSize:size];
    if (ScreenWidth == 414){
        size = size + 0.5;
    }else if(ScreenWidth ==375){
        size = size;
    }else{
        size = size - 0.5;
    }
    font = [UIFont systemFontOfSize:size];
    return font;
}
+ (UILabel *)setLabel_14_5_Size:(UILabel *)label {
    label.font = [self setlabelTextFontAdaptiveSize:14];
    return label;
}
#pragma mark - 对非纯数字的字符串进行邮箱判别
+(BOOL)MailboxDiscriminationForStringsThatAreNotPureNumbers:(NSString *)str
{
    if ([str containsString:@"@"]) {
        NSArray *array = [str componentsSeparatedByString:@"@"];
        NSString * rangStr = [NSString stringWithFormat:@"%@",array[1]];
        if([rangStr isEqualToString:@"gmail.com"]||[rangStr isEqualToString:@"yahoo.com"]||[rangStr isEqualToString:@"msn.com"]||[rangStr isEqualToString:@"hotmail.com"]||[rangStr isEqualToString:@"aol.com"]||[rangStr isEqualToString:@"ask.com"]||[rangStr isEqualToString:@"live.com"]||[rangStr isEqualToString:@"qq.com"]||[rangStr isEqualToString:@"0355.net"]||[rangStr isEqualToString:@"163.com"]||[rangStr isEqualToString:@"163.net"]||[rangStr isEqualToString:@"263.net"]||[rangStr isEqualToString:@"3721.net"]||[rangStr isEqualToString:@"yeah.net"]||[rangStr isEqualToString:@"googlemail.com"]||[rangStr isEqualToString:@"mail.com"]||[rangStr isEqualToString:@"126.com"]||[rangStr isEqualToString:@"188.com"]||[rangStr isEqualToString:@"yahoo.com.cn"]||[rangStr isEqualToString:@"sina.com"]||[rangStr isEqualToString:@"sohu.com"]||[rangStr isEqualToString:@"tom.com"]||[rangStr isEqualToString:@"kmvyhaxe.com"]||[rangStr isEqualToString:@"toncom.cn"]||[rangStr isEqualToString:@"cnool.net"]||[rangStr isEqualToString:@"21cn.com"]||[rangStr isEqualToString:@"china-fire.com"]||[rangStr isEqualToString:@"139.com"]||[rangStr isEqualToString:@"wo.cn"]||[rangStr isEqualToString:@"189.cn"]||[rangStr isEqualToString:@"icloud.com"]||[rangStr isEqualToString:@"iCloud.com"]||[rangStr isEqualToString:@"foxmail.com"]||[rangStr isEqualToString:@"56.com"]||[rangStr isEqualToString:@"outlook.com"]||[rangStr isEqualToString:@"aliyun.com"]||[rangStr isEqualToString:@"VIP.163.com"]||[rangStr isEqualToString:@"dingtalk.com"]||[rangStr isEqualToString:@"vip.qq.com"]||[rangStr isEqualToString:@"vip.sina.com"]){
            return YES;
        }else{
            return NO;
        }
    }else{
        return NO;
    }
}
#pragma mark - label自适应高度
+(CGFloat)labelAdaptiveAltitude:(CGFloat)width height:(CGFloat)height label:(UILabel *)label
{
    CGRect rect = [label.text boundingRectWithSize:CGSizeMake(width, height) options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: label.font} context:nil];
    CGFloat whatHeight = ceilf(rect.size.height);
    return whatHeight;
}

+(UILabel *)setAnySizeLabel :(UILabel *)label :(CGFloat)font
{
    label.font = [self setlabelTextFontAdaptiveSize:font];
    return label;
}
#pragma mark - 返回不一样的大小
+(CGFloat)initWithReturnsthesizeOf:(CGFloat)font :(CGFloat)poor{
    CGFloat Poor;
    if (ScreenWidth == 320) {
        Poor = font-poor;
    }else if(ScreenWidth == 375){
        Poor = font;
    }else {
        Poor = font+poor;
    }
    return Poor;
}
#pragma mark - 自适应宽度 高度不变
+(void)adaptiveWidth:(UILabel *)label str:(NSString *)str sizeMaxWidth:(CGFloat)sizeMaxWidth sizeMaxHeight:(CGFloat)sizeMaxHeight
{
    CGSize size = CGSizeMake(sizeMaxWidth, MAXFLOAT);//设置高度宽度的最大限度
    CGRect rect = [label.text boundingRectWithSize:size options:NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : label.font} context:nil];
    CGRect rect2 = label.frame;
    rect2.size.width = rect.size.width;
    label.frame = rect2;
}
#pragma mark - label自适应大小
+(void)setLabelAdaptiveSize:(UILabel *)label font:(CGFloat)font
{
    if (ScreenWidth == 320) {
        //5
        label.font = FONT_(font-0.5);
    }else if(ScreenWidth == 375){
        // 6 7
        label.font = FONT_(font);
    }else {
        //plus
        label.font = FONT_(font+0.5);
    }
}
#pragma mark - 专辑的浏览次数  转千  转万  保留2位小数
+(NSString *)theNumberViewsForTheAlbumAhanges:(NSString *)number
{
    NSInteger numberInt = [number integerValue];
    CGFloat value;
    NSString * string = [[NSString alloc]init];
    if (number.length>4) {
        //万
        value = numberInt *0.0001;
        string = @"万";
    }else{
        value = numberInt;
        string = @"";
    }
    CGFloat valueChange = round(value*100)/100;
    NSString * stringValue = [NSString stringWithFormat:@"%.2f",valueChange];
    //从第n为开始直到最后（包含第n位）
    NSArray *array = [stringValue componentsSeparatedByString:@"."];

    NSString * strOne = [NSString stringWithFormat:@"%@",array[0]];
    NSString * strTwo = [NSString stringWithFormat:@"%@",array[1]];
    if ([strTwo isEqualToString:@"00"]) {
        NSString * stringOne = [NSString stringWithFormat:@"%@%@",strOne,string];
        return stringOne;
    }else{
        NSString * str1 = [strTwo substringToIndex:1];//截取掉下标5之前的字符串
        NSString * str2 = [strTwo substringFromIndex:1];//截取掉下标3之后的字符串
        if ([str2 isEqualToString:@"0"]) {
            NSString * string1 = [NSString stringWithFormat:@"%@.%@%@",strOne,str1,string];
            return string1;
        }else{
            NSString * stringValue1 = [NSString stringWithFormat:@"%@%@",stringValue,string];
            return stringValue1;
        }
    }
}
#pragma mark - 时间戳1970不除以1000
+(NSString *)GetThePreviousTime :(NSString *)GetTime
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[GetTime doubleValue]];
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    return confromTimespStr;
}
#pragma mark - 浏览量
+(void)increaseTheNumberOfViews:(NSString *)id_id :(isOk)block
{
    [LSZRequestData AddVideoAudioTraffic :id_id :^(BOOL isOK, NSString * str, NSDictionary * dic) {
        if (isOK == YES) {
            block(YES);
        }else{
            block(NO);
        }
    }];
}
#pragma mark -记录视频的浏览记录
+(NSString *)recordTheBrowsingHistoryVideo
{
    NSString * str1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES)[0];
    return [str1 stringByAppendingPathComponent:[NSString stringWithFormat:@"VideoBrowsingHistory.text"]];
}
#pragma mark - 删除所有的缓存Documents
+(void)deleteAllCache
{
    NSString *DocumentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:DocumentsPath];
    for (NSString *fileName in enumerator) {
        [[NSFileManager defaultManager] removeItemAtPath:[DocumentsPath stringByAppendingPathComponent:fileName] error:nil];
    }
}
#pragma mark- 保存已下载视频的名字
+(NSString *)saveTheNameOfVideo
{
    NSString * str1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES)[0];
    return [str1 stringByAppendingPathComponent:[NSString stringWithFormat:@"Video.text"]];
}
#pragma mark - 下载视频
+(NSString *)DownloadTheVideo :(NSString *)path
{
    NSString * str1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES)[0];
    return [str1 stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",path]];
}
#pragma mark - 清除一些特定后缀的缓存
+(void)clearCacheSpecificSuffixes:(NSString *)str
{
    NSString *extension = str;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSArray *contents = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:nil];
    NSEnumerator *enumerator = [contents objectEnumerator];
    NSString *filename;
    while ((filename = [enumerator nextObject])) {
        if ([[filename pathExtension] isEqualToString:extension]) {
            [fileManager removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:filename] error:nil];
        }
    }
}
#pragma mark - 删除一些特定名字文件夹
+(void)deleteSomeSpecificFolders :(NSString *)strName
{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString * strN = [NSString stringWithFormat:@"%@",strName];
    [fileManager removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:strN] error:nil];
}

@end
